package com.eastfair.auth.controller;

import com.eastfair.auth.entity.SystemLog;
import com.eastfair.auth.dto.SystemLogSaveDTO;
import com.eastfair.auth.dto.SystemLogUpdateDTO;
import com.eastfair.auth.dto.SystemLogPageQuery;
import com.eastfair.auth.service.SystemLogService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import com.eastfair.annotation.annotation.security.PreAuth;

import com.eastfair.boot.request.PageParams;
import com.eastfair.core.context.ContextUtil;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 业务日志记录
 * </p>
 *
 * @author ligang
 * @date 2023-02-13
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/systemLog")
@Api(value = "SystemLog", tags = "业务日志记录")
@PreAuth(replace = "auth:systemLog:")
public class SystemLogController extends SuperController<SystemLogService, Long, SystemLog, SystemLogPageQuery, SystemLogSaveDTO, SystemLogUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Override
    public void handlerResult(IPage<SystemLog> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SystemLog> systemLogList = list.stream().map((map) -> {
            SystemLog systemLog = SystemLog.builder().build();
            //TODO 请在这里完成转换
            return systemLog;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(systemLogList));
    }



    /**
     * 处理参数
     *
     * @param params 分页参数
     */
    @Override
    public void handlerQueryParams(PageParams<SystemLogPageQuery> params) {
        SystemLogPageQuery pageQuery = params.getModel();

    }

}
